package Gather.StreamExercise.MethodReference.MethodExercise;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;

/**
 * ClassName:Methon001
 * Package:Gather.StreamExercise.MethodReference.MethodExercise
 * Description:
 *
 * @Author:ZhangXin
 * @Create2023/2/25-16:15
 * @Version:v1.0
 */
public class Method001 {
    /*练习
    * 集合中存储一些字符串的数据,比如：张三,23
    * 收集到Student类型的数组当中(使用方法引用)*/
    public static void main(String[] args) {
        ArrayList<String>list =new ArrayList<>();
        Collections.addAll(list,"赵小银,35","杨银,36","高圆圆,43","张甜甜,31","刘师,35","杨小幂,33");
        //收集到Student类型的数组当中(使用方法引用)
        //String -> Student
        //先把字符串变成Student对象,然后再把Student对象收集起来
        //收集到Student类型的数组当中5
        Student[] arr = list.stream().map(Student::new).toArray(Student[]::new);
        System.out.println(Arrays.toString(arr));
    }
}
